# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ranger-scanner
pkgver=149.3aae5dd
pkgrel=12
groups=('blackarch' 'blackarch-scanner' 'blackarch-recon')
pkgdesc='A tool to support security professionals to access and interact with remote Microsoft Windows based systems.'
arch=('any')
url='https://github.com/funkandwagnalls/ranger'
license=('custom:unknown')
depends=('python2' 'python2-python-nmap' 'python2-impacket' 'python2-lxml'
         'python2-netifaces' 'python2-netaddr' 'python2-pycryptodome'
         'python2-colorama' 'python2-setuptools')
makedepends=('git')
source=("$pkgname::git+https://github.com/funkandwagnalls/ranger.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|bin/env python|bin/env python2|g' ranger.py
  sed -i 's|from impacket.dcerpc import ndrutils, atsvc|from impacket.dcerpc.v5 import ndr, atsvc|' ranger.py
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 ranger.py "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

